import request from '@/utils/request'
import type { ApiResponse } from './components/ApiResponse'
import type { UserType } from '@/apis/components/userType'
import type { GoodsType } from './components/goodsType'

// 获取短信验证码
export const getSmsCodeApi = (mobile: string) => {
  return request.get<ApiResponse<null>>('/login/code', {
    params: {
      mobile,
    },
  })
}

// 根据用户名和密码登录
export const getLoginByPwdApi = (data: { account: string; password: string }) => {
  return request.post<ApiResponse<UserType>>('/login', data)
}

// 根据手机号和验证码登录
export const getLoginBySmsApi = (data: { mobile: string; code: string }) => {
  return request.post<ApiResponse<UserType>>('/login/code', data)
}

// 获取猜你喜欢数据列表
export const getLikeListAPI = (limit: number) => {
  return request.get<ApiResponse<[GoodsType]>>('/goods/relevant', {
    params: { limit },
  })
}
